package com.ys.controller.api.mall;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bo.vo.R;
import com.ys.entity.mall.TmOrder;
import com.ys.service.mall.TmOrderService;
import com.ys.service.sys.CommonApiService;
import com.ys.vo.LayuiTableVoJA;

@Controller
@RequestMapping("/api/inter/tmOrder")
public class ApiInterTmOrderController {
	@Autowired
	private CommonApiService<TmOrder> commonApiService;
	@Autowired
	private TmOrderService tmOrderService;

	@RequiresPermissions("tmOrder:view")
	@RequestMapping("/search")
	@ResponseBody
	public LayuiTableVoJA search(@ModelAttribute TmOrder cond){
		cond.setOrderby("A.Id desc");
		return commonApiService.searchLay(cond);
	}
	
	/**
	 * 新增
	 */
	@PostMapping("/commit")
    @ResponseBody
	public R commit(Long goodsId, Integer num, String address){

		try {
			return tmOrderService.commit(goodsId, num, address);
		} catch (Exception e) {
			e.printStackTrace();
			return R.error();
		}
	}
}